//============================================================================
// Name        : MANG1CHIEU.cpp
// Author      : contro
// Version     :
// Copyright   : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================

#include"khaibao.h"
int menu()
{
	int cv;
	do{
		cout<<"\n1.nhap mang 1 chieu so thuc.";
		cout<<"\n2.nhap mang 1 chieu so nguyen.";
		cout<<"\n3.xuat mang 1 chieu so thuc.";
		cout<<"\n4.xuat mang 1 chieu so nguyen.";
		cout<<"\n5.liet ke chan trong mang so nguyen.";
		cout<<"\n6.liet ke vi tri co gia tri am trong mang so thuc.";
		cout<<"\n7.vi tri hoan thien cuoi cung trong mang so nguyen.";
		cout<<"\n8.tim so duong nho nhat trong cac so thuc.";
		cout<<"\n9.so nguyen to dau trong mang so nguyen.";
		cout<<"\n10.so nguyen to lon nhat mang so nguyen.";
		cout<<"\n11.vi tri am lon nhat mang so thuc.";
		cout<<"\n12.gia tri xa x nhat.";
		cout<<"\n13.gia tri gan x nhat.";
		cout<<"\n14.tim doan [a,b] sao cho chua tat ca gia tri trong mang.";
		cout<<"\n15.xoa tat ca trung so nguyen.";
		cout<<"\n16.tong chan dau.";
		cout<<"\n17.vi tri le tang.";
		cout<<"\n18.so nguyen ro tang.";
		cout<<"\n19.chan le tang.";
		cout<<"\nmoi ban chon cong viec: ";
		cin>>cv;
	}while(cv<0);
	return cv;
}
int main() {
	int *p,n,m,cv,x;
	float *q;
	do{
		cv=menu();
		switch(cv)
		{
		case 1:
			cout<<"nhap so pt: ";
			cin>>m;
			q=new float [m];
			NhapSoThuc(q,m);
			break;
		case 2:
			cout<<"nhap so pt: ";
			cin>>n;
			p=new int [n];
			Nhap(p,n);
			break;
		case 3:
			XuatSoThuc(q,m);
			break;
		case 4:
			Xuat(p,n);
			break;
		case 5:
			LietKeChan(p,n);
			break;
		case 6:
			ViTriAm(q,m);
			break;
		case 7:
			if(VTHoanThienCuoiCung(p,n)==-1)
				cout<<"khong co so hoan thien";
			else
				cout<<"vi tri so hoan thien cuoi cung la: "<<VTHoanThienCuoiCung(p,n);
			break;
		case 8:
			if(DuongNN(q,m)==-1)
				cout<<"khong co so duong nao.";
			else
				cout<<"duong nho nhat la: "<<DuongNN(q,m);
			break;
		case 9:
			if(SoNTDau(p,n)==-1)
				cout<<"khong co so nguyen to nao.";
			else
				cout<<"snt dau la: "<<SoNTDau(p,n);
			break;
		case 10:
			if(SoNTLonNhat(p,n)==0)
				cout<<"khong co so nguyen to nao.";
			else
				cout<<"so nguyen to lon nhat la: "<<SoNTLonNhat(p,n);
			break;
		case 11:
			if(ViTriAmLonNhat(q,m)==-1)
				cout<<"khong co vi tri nao co so am.";
			else
				cout<<"vi tri co so am lon nhat la: "<<ViTriAmLonNhat(q,m);
			break;
		case 12:
			cout<<"moi ban nhap x: ";
			cin>>x;
			cout<<"gia tri xa "<<x<<" nhat la: "<<XaGiaTriXNhat(p,n,x);
			break;
		case 13:
			cout<<"moi ban nhap x: ";
			cin>>x;
			cout<<"gia tri gan "<<x<<" nhat la: "<<GanGiaTriXNhat(p,n,x);
			break;
		case 14:
			TimDoan(q,m);
			break;
		case 15:
			XoaTatCaTrung(p,n);
			break;
		case 16:
			cout<<TongDauChan(p,n);
			break;
		case 17:
			ViTriLeTang(p,n);
			break;
		case 18:
			NguyenToTang(p,n);
			break;
		case 19:
			ChanLeTang(p,n);
			break;
		default:
			cout<<"khong co cong viec nay.";
			break;
		}
		cout<<"\n========================================";
	}while(cv!=0);
	return 0;
}
